package com.bai.statistics.schedule;

import com.bai.statistics.service.DailyService;
import com.bai.utils.DataUtils;
import net.sf.jsqlparser.expression.DateTimeLiteralExpression;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * 定时任务
 */
@Component
public class ScheduleTask {

    @Autowired
    private DailyService dailyService;

    //TODO: 0/5 * * * * ? 每个五秒执行一次
    @Scheduled(cron = "0/5 * * * * ?")
    public void task1(){
        System.out.println("task1执行了......");
    }

    //TODO:每天凌晨一点执行前一天的数据
    @Scheduled(cron = "0 0 1 * * ?")
    public void task2(){
        dailyService.registerCount(DataUtils.formatDate(DataUtils.addDays(new Date(), -1)));
    }


}
